<template>
  <div class="self_adaption">
    <p style="line-height: 50px; font-size: 16px; font-weight: bold" class="main_text">素材中心</p>
    <div class="g_main">
      <div class="g_main_title">
        <p style="margin-right: 16px; color: #116cf8">图片</p>
        <p>视频</p>
      </div>
      <div class="g-container">
        <div class="g_container_left">
          <div>
            <div class="g_container_left_main">
              <div class="g_container_left_min">
                <div>
                  <el-icon>
                    <Folder />
                  </el-icon>
                </div>
                <p style="font-size: 14px">全部图片</p>
              </div>
              <el-icon>
                <More />
              </el-icon>
            </div>
            <el-tree
              ref="treeRef"
              class="filter-tree"
              :data="data"
              :icon="Folder"
              :props="defaultProps"
              default-expand-all
              :filter-node-method="filterNode"
              @node-click="treeClick" />
          </div>
          <div style="margin-bottom: 40px">
            <el-button size="small" type="primary" plain>添加文件夹</el-button>
            <el-button size="small" type="primary" plain>管理文件夹</el-button>
          </div>
        </div>

        <!-- 右边内容 -->
        <div class="g_container_right">
          <p>全部图片</p>
          <div style="margin-top: 8px">
            <el-button size="small" type="primary">添加文件夹</el-button>
            <el-button size="small" plain type="primary">批量删除</el-button>
            <el-select size="small" v-model="select" placeholder="按时间排序" style="width: 115px; margin-left: 12px">
              <el-option label="从大到小" value="1" />
              <el-option label="从小到大" value="2" />
            </el-select>
            <el-input
              size="small"
              v-model="input1"
              placeholder="搜索"
              :prefix-icon="Search"
              style="width: 160px; margin-left: 12px" />
          </div>

          <!-- 表格 -->
          <el-table
            size="small"
            ref="multipleTableRef"
            :data="tableData"
            style="width: 100%; margin-top: 20px"
            @selection-change="handleSelectionChange"
            :show-overflow-tooltip="true">
            <el-table-column type="selection" />
            <el-table-column label="图片文件">
              <el-icon size="40">
                <Folder />
              </el-icon>
            </el-table-column>
            <el-table-column property="name" label="商品名称" />

            <el-table-column property="size" label="大小" />
            <el-table-column property="Ctime" label="创建时间" />
            <el-table-column property="Utime" label="更新时间" />
            <el-table-column label="状态">
              <el-button link type="success">启用</el-button>
            </el-table-column>
            <el-table-column label="操作">
              <el-button link type="primary">修改</el-button>
              <el-button link type="danger">删除</el-button>
            </el-table-column>
          </el-table>

          <!-- 图片 -->
          <!-- <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">Checkall</el-checkbox> -->
          <!-- <div>
                    <div style="display: flex;align-items: center;margin-top: 10px;">
                        <el-checkbox size="small">当页全选</el-checkbox>
                        <el-button size="small" link type="primary">修改</el-button>
                        <el-button size="small" link type="danger">删除</el-button>
                    </div>
                    <el-upload class="g_container_right_main" action="#" list-type="picture-card" :auto-upload="false"
                        :on-change="selectFiles" v-model:file-list="photo" v-if="uploadShow">
                        <el-icon>
                            <Plus />
                        </el-icon>

                        <template #file="{ file }">
                            <div>
                                <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                            </div>
                        </template>
                    </el-upload>
                </div> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const select = ref(''); //输入框
const input1 = ref(''); //输入框
import {ref} from 'vue';
import {Photo} from '../../../hooks/Article/Photo';
import {Folder, More, Search} from '@element-plus/icons-vue';
import {ElTree, ElTable} from 'element-plus';
const {data, defaultProps, treeClick} = Photo();
// const treeRef = ref<InstanceType<typeof ElTree>>()

/* 表格 */
const multipleTableRef = ref<InstanceType<typeof ElTable>>();
const multipleSelection = ref<any>([]);
const handleSelectionChange = (val: any) => {
  multipleSelection.value = val;
};
const tableData: any = [
  {
    name: '商品1图片',
    size: '500M',
    Ctime: '2023-09-21 18:08',
    Utime: '2023-09-21 18:08',
    status: 1,
  },
  {
    name: '商品2图片',
    size: '500M',
    Ctime: '2023-09-21 18:08',
    Utime: '2023-09-21 18:08',
    status: 1,
  },
  {
    name: '商品3图片',
    size: '500M',
    Ctime: '2023-09-21 18:08',
    Utime: '2023-09-21 18:08',
    status: 1,
  },
];
</script>

<style lang="scss" scoped>
.g_main {
  height: calc(100% - 42px);
  background-color: #fff;

  .g_main_title {
    padding: 16px 24px 8px;
    box-sizing: border-box;
    border-bottom: 1px solid #eee;
    display: flex;
    font-size: 14px;
    color: #666;
    user-select: none;

    :hover {
      color: #116cf8;
      // border-bottom: 1px solid #116CF8;
    }
  }

  .g-container {
    width: 100%;
    padding: 0 16px 0;
    box-sizing: border-box;
    height: calc(100% - 48px);
    display: flex;
  }

  .g_container_left {
    height: 100%;
    padding-right: 20px;
    box-sizing: border-box;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .g_container_left_main {
      margin-top: 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .g_container_left_min {
        display: flex;
        align-items: center;
        justify-content: space-between;

        div {
          width: 24px;
          height: 24px;
          background-color: #116cf8;
          border-radius: 4px;
          text-align: center;
          line-height: 28px;
          margin-right: 10px;

          :deep .el-icon {
            color: #fff;
          }
        }
      }
    }
  }

  .filter-tree {
    margin-top: 16px;
    width: 160px;
    margin-right: 30px;
  }

  .g_container_right {
    padding: 16px 16px;
    width: calc(100% - 200px);

    .g_container_right_main {
      margin-top: 16px;
    }
  }

  .photo_file {
    display: flex;
    flex-wrap: wrap;
  }

  .form_box {
    padding-top: 20px;
    width: 150px;
    height: 150px;
    position: absolute;
    left: 50%;
    margin-left: -75px;
    bottom: 30px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;

    .img_upload_line {
      display: flex;

      .img_upload_box {
        width: 150px;
        height: 150px;
        overflow: hidden;
      }
    }

    .upload {
      margin-top: 10px;
    }
  }

  :deep .el-icon {
    color: #116cf8;
    transform: none;
  }
}
</style>
